Product
Introducing License Enforcement in Socket
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
@lingui/babel-plugin-extract-messages
Advanced tools
Babel plugin for collecting messages from source code for internationalization
@lingui/babel-plugin-extract-messages is a Babel plugin designed to extract messages from your code for internationalization (i18n) purposes. It works in conjunction with the LinguiJS framework to help developers manage and translate text in their applications.
Extracting Messages
This feature allows you to extract messages from your codebase into a specified directory. The configuration specifies the directory where the extracted messages will be stored and whether to extract messages from `formatMessage` calls.
```json
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
[
"@lingui/babel-plugin-extract-messages",
{
"localeDir": "./locales/",
"extractFromFormatMessageCall": true
}
]
]
}
```
Custom Message Extraction
This feature allows you to define custom formatters for message extraction. The configuration includes a custom formatter with a specific name and pattern, enabling more flexible message extraction.
```json
{
"presets": ["@babel/preset-env", "@babel/preset-react"],
"plugins": [
[
"@lingui/babel-plugin-extract-messages",
{
"localeDir": "./locales/",
"extractFromFormatMessageCall": true,
"customFormatters": [
{
"name": "customFormatter",
"pattern": "customPattern"
}
]
}
]
]
}
```
babel-plugin-react-intl is a Babel plugin for extracting messages from React components that use the react-intl library. It is similar to @lingui/babel-plugin-extract-messages but is specifically designed for use with react-intl, making it a good choice for projects already using that library.
i18next-extract-gettext is a tool for extracting translation keys from JavaScript and TypeScript codebases that use the i18next library. It provides similar functionality to @lingui/babel-plugin-extract-messages but is tailored for use with i18next, offering a different approach to internationalization.
Babel plugin which extracts messages for translation from source files
@lingui/babel-plugin-extract-messages
is part of LinguiJS. See the documentation for all information, tutorials and examples.
npm install --save-dev @lingui/babel-plugin-extract-messages
# yarn add --dev @lingui/babel-plugin-extract-messages
.babelrc
(Recommended).babelrc
{
"plugins": ["@lingui/babel-plugin-extract-messages"]
}
babel --plugins @lingui/babel-plugin-extract-messages script.js
require("@babel/core").transform("code", {
plugins: ["@lingui/babel-plugin-extract-messages"]
})
3.17.2 (2023-02-24)
missing
in setupI18nProps
(#1411) (6459f02)FAQs
Babel plugin for collecting messages from source code for internationalization
We found that @lingui/babel-plugin-extract-messages demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Product
Ensure open-source compliance with Socket’s License Enforcement Beta. Set up your License Policy and secure your software!
Product
We're launching a new set of license analysis and compliance features for analyzing, managing, and complying with licenses across a range of supported languages and ecosystems.
Product
We're excited to introduce Socket Optimize, a powerful CLI command to secure open source dependencies with tested, optimized package overrides.